package com.youedata.modular.enums;

public enum RoleFlag {
    /**
     * 角色
     */
    ADMIN("admin", "超级管理员"),
    AREA_ADMIN("area_admin", "区域管理员"),
    DEPT_MANAGER("dept_manager", "项目部经理"),
    DEPT_MEMBER("dept_member", "项目部成员"),
    HEADER_TEACHER("herder_teacher", "班主任"),
    TEACHER("teacher", "教师");

    private String code;
    private String desc;

    RoleFlag(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static RoleFlag getByCode(String code) {
        RoleFlag[] values = values();
        for (RoleFlag sw : values) {
            if (sw.code.equals(code)) {
                return sw;
            }
        }
        return null;
    }

    public static RoleFlag getByDesc(String desc) {
        RoleFlag[] values = values();
        for (RoleFlag sw : values) {
            if (sw.desc.equals(desc)) {
                return sw;
            }
        }
        return null;
    }


    public static Boolean checkCode(String code) {
        RoleFlag[] values = values();
        for (RoleFlag sw : values) {
            if (sw.code.equals(code)) {
                return true;
            }
        }
        return false;
    }

    public static Boolean checkDesc(String desc) {
        RoleFlag[] values = values();
        for (RoleFlag sw : values) {
            if (sw.desc.equals(desc)) {
                return true;
            }
        }
        return false;
    }
}
